package com.lyl.springcloud.controller;

import com.lyl.springcloud.model.Payment;
import com.lyl.springcloud.model.Result;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * @author lylbell
 * @date 2021-06-06 20:58
 */
@RestController
public class PaymentController {

    @Value("${server.port}")
    private String serverPort;

    public static HashMap<Long, Payment> hashMap = new HashMap<>();

    static {
        hashMap.put(1L,new Payment(1L,"fksdfjkadfjkajfdkjsd1"));
        hashMap.put(2L,new Payment(2L,"fksdfjkadfjkajfdkjsd2"));
        hashMap.put(3L,new Payment(3L,"fksdfjkadfjkajfdkjsd3"));
    }

    @GetMapping("/paymentSQL/{id}")
    public Result paymentSQL(@PathVariable("id") Long id) {
        Payment payment = hashMap.get(id);
        return new Result(200,serverPort,payment);
    }
}
